#include "Mutex.h"

Mutex::Mutex(void)
{
    pthread_mutexattr_t attr;
    pthread_mutexattr_init(&attr);
    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
    pthread_mutex_init(&m_mutex, &attr);
    pthread_mutexattr_destroy(&attr);
}

Mutex::~Mutex(void)
{
    pthread_mutex_destroy(&m_mutex);
}

int Mutex::Lock()
{
    return pthread_mutex_lock(&m_mutex);
}

int Mutex::TryLock()
{
    return pthread_mutex_trylock(&m_mutex);
}

int Mutex::Unlock()
{
    return pthread_mutex_unlock(&m_mutex);
}


